const mongoose = require('mongoose')
const { dbHost } = require('../../conf/index')
const { generateId } = require('../../utils/index')

const connection = mongoose.createConnection(`mongodb://${dbHost}/manage_db`)

const Schema = mongoose.Schema

const songtSchema = new Schema({
  // commentNo:{type:String,required:true},// 评论外键
  songNo: {
    type: String,
    default() {
      return generateId('GQ')
    }
  },
  songlistNo: { type: String, required: [true, '歌单编号为空'] }, // 歌单外键
  songerNo: { type: String, required: [true, '歌手编号为空'] }, // 歌手外键
  songName: {
    type: String,
    default() {
      return '' // 歌曲名
    }
  },
  description: { type: String, default: '' }, // 简介
  songUrl: { type: Object, required: [true, '歌曲url为空'] },
  collectNum: { type: Number, default: 0 } // 收藏量
})

module.exports = connection.model('song', songtSchema)
